<?php
header('Content-Type: application/json; charset=utf-8');

//

//
$students = [
    1 => '张三',
    2 => '李四',
    3 => '王五',
];

//
$grades = [
    '1_1' => 88, '1_2' => 92, '1_3' => 79,
    '2_1' => 76, '2_2' => 81, '2_3' => 90,
    '3_1' => 85, '3_2' => 67, '3_3' => 73,
];

//
$studentId = isset($_REQUEST['student_id']) ? intval($_REQUEST['student_id']) : 0;
$courseId = isset($_REQUEST['course_id']) ? intval($_REQUEST['course_id']) : 0;
$key       = "{$studentId}_{$courseId}";

//
if ($studentId && $courseId && isset($grades[$key]) && isset($students[$studentId])) {
    $response = [
        'stat' => 1,
        'msg'  => '',
        'data' => [
            'student_id'   => $studentId,
            'student_name' => $students[$studentId],
            'course_id'   => $courseId,
            'grade'        => $grades[$key],
        ],
    ];
} else {
    $response = [
        'stat' => 0,
        'msg'  => '未找到对应学生或成绩',
        'data' => null,
    ];
}

echo json_encode($response, JSON_UNESCAPED_UNICODE);
